home *** CD-ROM | disk | FTP | other *** search
/ Tripas 5 / TRIPAS 005.iso / Wos.EXE / 2015 / global / mthug.scr < prev    next >
Encoding:
Text File  |  1999-02-24  |  15.0 KB  |  608 lines

  1. // DESCRIPTION:
  2. // AI script for Menero's Thug.
  3. //
  4. // AUTHOR:
  5. // Boon
  6. // BEGUN:
  7. // 28th October 1998
  8.  
  9. //Menero's Thug is an enemy, meaning he will attack hardcorps guys
  10. local.self enemy
  11. //Tell him to ignore everything and then, below, change
  12. //particular states so he won't ignore them
  13. local.self ignoreall
  14.  
  15. //
  16. // Define the default states for Mr Thug
  17. // Note that these are often changed in level scripts anyhow
  18. //
  19. local.self definestate idle                global/baseai.scr::idle
  20. local.self definestate twitch                 global/baseai.scr::twitch
  21. local.self definestate pain                global/baseai.scr::pain
  22. local.self definestate opendoor            global/baseai.scr::opendoor
  23. local.self definestate activate            global/baseai.scr::attackentity
  24. local.self definestate use                global/baseai.scr::attackentity
  25. local.self definestate jump                      global/baseai.scr::jump
  26.  
  27. local.self definestate sightenemy           sightenemy
  28. //local.self definestate sightenemy           global/baseai.scr::sightenemy
  29. //Manero's Thugs have a different attacking behaviour from standard monsters
  30. local.self definestate duckandcover            duckandcover
  31. local.self definestate standground            global/baseai.scr::standground
  32. local.self definestate blitzattack           global/baseai.scr::blitz_attack
  33. local.self definestate meleeattack             global/baseai.scr::meleeattack
  34.  
  35. local.self definestate default_sightenemy     global/baseai.scr::sightenemy
  36. //local.self definestate simpleattack           duckandcover
  37. local.self definestate simpleattack           global/baseai.scr::attackentity
  38. //local.self definestate weaponsound            maybe_protect_head
  39. local.self definestate weaponsound            global/baseai.scr::urgent_investigate
  40. local.self definestate movementsound        global/baseai.scr::investigate
  41. local.self definestate painsound            global/baseai.scr::investigate
  42. local.self definestate deathsound            investigate
  43. // This makes them duck if you whizz a bullet past their ear (well, it's 
  44. // not that good, but occasionally it gives that impression)
  45. local.self definestate breakingsound        protect_head
  46. //local.self definestate breakingsound        global/baseai.scr::urgent_investigate
  47. local.self definestate doorsound            global/baseai.scr::investigate
  48. local.self definestate mutantsound            global/baseai.scr::urgent_investigate
  49. local.self definestate voicesound            global/baseai.scr::investigate
  50. local.self definestate radiosound            global/baseai.scr::investigate
  51.  
  52. //goto global/baseai.scr::init
  53. goto init
  54.  
  55. end
  56.  
  57.  
  58. //************************************************************
  59. //
  60. // protect_head:
  61. //
  62. // When the Thug hears a gunshot, his first instinct is to 
  63. // duck.  He then looks around a bit, and then goes and has
  64. // a look.
  65. //
  66. //************************************************************
  67.  
  68. protect_head:
  69.  
  70. // increase his paranoia
  71. local.paranoia += 6
  72.  
  73. //local.randchoice randomint 3
  74. //local.randchoice ifequal 0 goto global/baseai.scr::urgent_investigate
  75. local.self anim crouch
  76. waitFor local.self
  77. local.self anim crouch_idle
  78.  
  79. local.self lookAt local.other
  80. wait 1
  81.  
  82. // turn a bit
  83. parm.yaw = local.yaw
  84. parm.yaw += 140
  85. local.self turnto parm.yaw
  86. local.randchoice randomint 2
  87. local.randchoice /= 2
  88. wait local.randchoice
  89.  
  90. // turn a bit more
  91. parm.yaw = local.yaw
  92. parm.yaw += 50
  93. local.self turnto parm.yaw
  94. local.randchoice randomint 3
  95. local.randchoice /= 2
  96. wait local.randchoice
  97.  
  98. local.randchoice randomint 15
  99. local.randchoice ifequal 1 goto protecthead_step
  100. goto protecthead_continue
  101.  
  102. protecthead_step:
  103.  
  104. local.self anim "crouch_walk"
  105. waitFor local.self
  106.  
  107. protecthead_continue:
  108.  
  109. // turn a bit more
  110. parm.yaw = local.yaw
  111. parm.yaw += 20
  112. local.self turnto parm.yaw
  113. //wait 2
  114.  
  115. //Stay ducked for up to 2 more seconds
  116. local.randchoice randomint 2
  117. local.randchoice ifequal 0 local.randchoice += 1
  118. wait local.randchoice
  119.  
  120. local.self anim "crouch_return"
  121. waitFor local.self
  122. goto investigate
  123.  
  124. //************************************************************
  125. // Maybe_protect_head
  126. //************************************************************
  127.  
  128. maybe_protect_head:
  129.  
  130. local.randchoice randomint 2
  131. local.randchoice ifequal 1 goto global/baseai.scr::urgent_investigate
  132.  
  133. // Decrease his paranoia because protect_head will increase it again
  134. local.paranoia -= 3
  135.  
  136. goto protect_head
  137.  
  138. //************************************************************
  139. //
  140. // investigate:
  141. // Actor walks to location and fights enemies along the way.
  142. // If really paranoid, runs to location.
  143. //
  144. // My version just alters the behaviour a little, makes them 
  145. // duck a bit, etc
  146. //
  147. //************************************************************
  148.  
  149. investigate:
  150.  
  151. // see if we are in stand ground mode
  152. // if we are we don't want to investigate
  153. local.attackmode ifequal 1 goto dont_investigate
  154.  
  155. // increase his paranoia
  156. local.paranoia += 2
  157.  
  158. // Just look at the cause
  159. local.paranoia ifgreater 9 goto skiplook
  160. local.self anim idle
  161. local.self lookAt local.other
  162. wait 0.6
  163.  
  164. skiplook:
  165.  
  166. // if paranoid, go check it out
  167. local.paranoia ifgreater 6 goto investigate_walkover
  168.  
  169. wait 5
  170.  
  171. // go back to what we were doing
  172. end
  173.  
  174. investigate_walkover:
  175.  
  176. local.self clearstate
  177.  
  178. // normally, just walk over
  179. parm.anim string "walk"
  180.  
  181. // if really paranoid run over there
  182. local.paranoia ifgreater 8 parm.anim string "run"
  183.  
  184. local.self behavior Investigate parm.anim local.location
  185. waitFor local.self
  186.  
  187. //if really really paranoid, crouch while looking
  188. local.paranoia ifless 11 goto investigate_stand
  189.  
  190. investigate_duck:
  191.  
  192. local.self anim crouch
  193. waitFor local.self
  194. local.self anim crouch_idle
  195.  
  196. // turn a bit
  197. parm.yaw = local.yaw
  198. local.randchoice randomint 8
  199. local.randchoice *= 10
  200. local.randchoice += 30
  201. parm.yaw += local.randchoice
  202. local.self turnto parm.yaw
  203.  
  204. // Maybe shuffle forward a bit
  205. local.randchoice randomint 20
  206. local.randchoice ifequal 1 goto investigate_step1
  207. goto investigate_continue1
  208.  
  209. investigate_step1:
  210.  
  211. // Don't step if we are really paranoid since we'll be here again and
  212. // we don't want to step too many times.
  213. local.paranoia ifgreater 14 goto investigate_continue1
  214. local.self anim "crouch_walk"
  215. waitFor local.self
  216.  
  217. investigate_continue1:
  218.  
  219. // Turn a bit more
  220. parm.yaw = local.yaw
  221. parm.yaw -= 50
  222. local.self turnto parm.yaw
  223. local.randchoice randomint 4
  224. local.randchoice /= 2
  225. wait local.randchoice
  226.  
  227. // Perhaps shuffle again
  228. local.randchoice randomint 15
  229. local.randchoice ifequal 1 goto investigate_step2
  230. goto investigate_continue2
  231.  
  232. investigate_step2:
  233.  
  234. // Don't step if we are really paranoid since we'll be here again and
  235. // we don't want to step too many times.
  236. local.paranoia ifgreater 14 goto investigate_continue1
  237. local.self anim "crouch_walk"
  238. waitFor local.self
  239.  
  240. investigate_continue2:
  241.  
  242. // turn a bit more
  243. parm.yaw = local.yaw
  244. parm.yaw += 50
  245. local.self turnto parm.yaw
  246.  
  247. //Stay ducked for up to 3 more seconds
  248. local.randchoice randomint 2
  249. local.randchoice += 1
  250. wait local.randchoice
  251.  
  252. // OK, so we've looked around, and haven't seen anyone
  253. local.paranoia -= 5
  254. local.paranoia ifgreater 9 goto investigate_duck
  255. local.self anim "crouch_return"
  256. waitFor local.self
  257. local.paranoia ifless 4 goto dont_investigate
  258.  
  259. investigate_stand:
  260.  
  261. // stand around for a bit
  262. local.self anim idle
  263. local.self lookAt local.other
  264. wait 2
  265.  
  266. // turn a bit
  267. parm.yaw = local.yaw
  268. parm.yaw += 70
  269. local.randchoice randomint 2
  270. local.randchoice /= 2
  271. wait local.randchoice
  272.  
  273. // turn a bit
  274. parm.yaw = local.yaw
  275. parm.yaw += 50
  276. local.randchoice randomint 3
  277. local.randchoice /= 3
  278. wait local.randchoice
  279.  
  280. // turn a bit more
  281. parm.yaw = local.yaw
  282. parm.yaw += 110
  283. local.self turnto parm.yaw
  284. local.randchoice randomint 5
  285. local.randchoice /= 2
  286. wait local.randchoice
  287.  
  288. // Hmmm, didn't see anything.  Must have been nothing.
  289. // Go back to where we started
  290. local.self walkto local.startpos
  291. waitFor local.self
  292.  
  293. local.self state idle
  294. end
  295.  
  296. dont_investigate:
  297. //
  298. // since we are in stand ground,
  299. // Just look at the cause
  300. //
  301. local.self anim idle
  302. local.self lookAt local.other
  303. wait 0.4
  304. end
  305.  
  306.  
  307. //***************************************************************
  308. //                                                               
  309. // duckandcover:
  310. // In this version of duckandcover, he tries to plug his enemy
  311. // without coming out from behind his cover.
  312. //
  313. // This is based off SiN's duckandcover code.
  314. //
  315. //****************************************************************
  316.  
  317. duckandcover:
  318.  
  319. local.self ifcanmeleeattack goto duckandcover_melee
  320.  
  321. // find our enemy
  322. // (Boon) FindEnemy moves around the pathnodes until it 
  323. // determines that it can shoot the enemy, or gives up.
  324. local.self behavior FindEnemy "run"
  325. waitFor local.self
  326.  
  327. //
  328. // in case we couldn't get to the enemy at all
  329. //
  330. local.enemy ifstrequal "" goto duckandcover_end
  331.  
  332. //
  333. // can we get a bead on him
  334. //
  335. local.self ifcanshoot goto duckandcover_continue
  336.  
  337. //
  338. // otherwise continue searching
  339. //
  340. goto duckandcover
  341.  
  342.  
  343. duckandcover_continue:
  344. //
  345. //Since the Thug should be good at shooting from behind cover, he is
  346. //more likely to run and hide.
  347. //
  348. local.randchoice randomint 2
  349. //local.randchoice ifequal 0 goto duckandcover_hide
  350. local.randchoice ifequal 0 local.self behavior FindCover "run"
  351.  
  352. local.self ifcanstrafeattack goto duckandcover_strafeattack
  353.  
  354. //
  355. // take 5 shots
  356. // (Boon) What's this about 5?  I don't see where 5 came from
  357. // 5 is actually a typical value for local.shots_per_attack I think
  358. //
  359. local.shotsleft = 1
  360.  
  361.  
  362. duckandcover_shoot:
  363. local.self behavior AimAndShoot local.shots_per_attack
  364. waitFor local.self
  365. local.shotsleft -= 1
  366.  
  367. local.enemy ifstrequal "" goto duckandcover_end
  368. //
  369. // did he lose his weapon
  370. //
  371. local.has_weapon ifequal 0 goto duckandcover_evaluate
  372.  
  373. local.shotsleft ifgreater 0 goto duckandcover_shoot
  374.  
  375.  
  376. //***********************
  377. // Duckandcover_hide
  378. //***********************
  379.  
  380. duckandcover_hide:
  381. //
  382. // run and hide
  383. //
  384. //local.self behavior FindCover "run"
  385. //waitFor local.self
  386. local.enemy ifstrnotequal "" local.self lookat local.enemy
  387.  
  388. // Generate a time between 1 and 3 seconds to stay down for
  389. local.hidetime = game.time
  390. local.hidetime += 2
  391. //local.randchoice randomint 2
  392. //local.hidetime += local.randchoice
  393.  
  394. //
  395. // Now duck, and call the code that makes him shoot while ducked
  396. //
  397. local.self anim crouch
  398. //local.enemy ifstrnotequal "" local.self lookat local.enemy
  399. waitfor local.self 
  400. local.self anim crouch_idle
  401.  
  402. duckandcover_hide_shoot:
  403.  
  404. // DuckAttack is causing some problems:
  405. // If we go through once, and then again immediately after,
  406. // or something like that, it seems to lock the thug in position,
  407. // which is bad.
  408. local.self behavior DuckAttack 
  409. waitfor local.self
  410. local.self behavior Lean_AimandShoot local.shots_per_attack "crouch_"
  411. waitfor local.self
  412. wait 0.5
  413.  
  414. duckandcover_wait:
  415. //
  416. // Get up if we're seen, otherwise, usually stay down and keep killing (heh)
  417. //
  418. local.self ifenemyvisible goto duckandcover_unhide
  419. //local.self ifenemyvisible goto duckandcover_done
  420.  
  421. local.randchoice randomint 10
  422. local.randchoice ifequal 0 goto duckandcover_done
  423. goto duckandcover_hide_shoot
  424.  
  425. duckandcover_done:
  426. game.time ifless local.hidetime goto duckandcover_wait
  427.  
  428. duckandcover_unhide:
  429. local.self anim "crouch_return"
  430. waitfor local.self
  431. goto duckandcover
  432.  
  433.  
  434. //******************
  435. // Strafe attack
  436. //******************
  437.  
  438. duckandcover_strafeattack:
  439.  
  440. // try to fire right away
  441. local.self behavior AimAndShoot local.shots_per_attack
  442. waitFor local.self
  443. local.enemy ifstrequal "" goto duckandcover_end
  444. // did he lose his weapon
  445. local.has_weapon ifequal 0 goto duckandcover_evaluate
  446.  
  447. local.oldpos vector local.origin
  448. local.self reservenode local.oldpos 10
  449. local.self behavior StrafeAttack
  450. waitFor local.self
  451.  
  452. local.self behavior AimAndShoot local.shots_per_attack
  453. waitFor local.self
  454. local.enemy ifstrequal "" goto duckandcover_end
  455. // did he lose his weapon
  456. local.has_weapon ifequal 0 goto duckandcover_evaluate
  457.  
  458. local.self ifcanhideat local.oldpos goto duckandcover_strafehide
  459. local.self releasenode local.oldpos
  460.  
  461. local.self behavior FindCover "run"
  462. waitFor local.self
  463. goto duckandcover_hide
  464. //goto duckandcover
  465.  
  466. duckandcover_strafehide:
  467. // This strafes back to somewhere where he could hide
  468.  
  469. local.self behavior StrafeTo local.oldpos
  470. waitFor local.self
  471.  
  472. goto duckandcover_hide
  473. //local.self usecover
  474. //local.hidetime = game.time
  475. //local.hidetime += 2
  476. //goto duckandcover_wait
  477.  
  478. duckandcover_end:
  479. end
  480.  
  481. duckandcover_melee:
  482.  
  483. local.self behavior AimAndMelee local.shots_per_attack
  484. waitFor local.self
  485. goto duckandcover
  486. end
  487.  
  488. //************************************************************
  489. //
  490. // sightenemy:
  491. // Same as the regular sightenemy, except that he 
  492. // doesn't ignore breaking sounds any more
  493. //
  494. //************************************************************
  495.  
  496. sightenemy:
  497.  
  498. local.self clearstate
  499.  
  500. // crank up his paranoia level
  501. local.paranoia += 20
  502.  
  503. local.self respondtoall
  504. local.self ignore    activate    use
  505. local.self ignoresounds
  506. //local.self definestate breakingsound maybe_protect_head
  507.  
  508. duckandcover_evaluate:
  509. //
  510. // see if we lost our weapon or never had one
  511. //
  512. local.has_weapon ifequal 0 local.self state meleeattack
  513. local.attackmode ifequal 0 local.self state duckandcover
  514. local.attackmode ifequal 1 local.self state standground
  515. local.attackmode ifequal 2 local.self state blitzattack
  516. local.self state idle
  517. end
  518.  
  519.  
  520. //************************************************************
  521. //
  522. // init:
  523. // Initialize variables and "hidden" states and goto idle state.
  524. //
  525. // I had to move this here so it would call the proper idle...
  526. //
  527. //************************************************************
  528.  
  529. init:
  530.  
  531. local.paranoia = 0
  532. local.self state idle
  533.  
  534. end
  535.  
  536. //************************************************************
  537. //
  538. // idle:
  539. // Alert, but standing around waiting for action.
  540. // Altered to allow for smokos.
  541. //
  542. // Smoko stuff doesn't work, plus it would be setting a bad 
  543. // example for the kids, plus the tech_guards don't have smoko 
  544. // animations anyhow, so I've removed it.
  545. //
  546. //************************************************************
  547.  
  548. idle:
  549.  
  550. local.self clearstate
  551. local.self respondtoall
  552.  
  553. idle_loop:
  554.  
  555. local.self idle "idle"
  556. waitFor local.self
  557.  
  558. //local.randchoice randomint 5
  559. //local.randchoice ifequal 1 goto have_smoko
  560.  
  561. goto idle_loop
  562.  
  563. have_smoko:
  564. local.self state smoko
  565.  
  566. end
  567.  
  568. //***************************************************************
  569. //
  570. // Smoko stuff
  571. //
  572. //***************************************************************
  573.  
  574. smoko:
  575.  
  576. local.self clearstate
  577. local.self respondtoall
  578.  
  579. local.self anim "smoke_start"
  580. //Need to set a time here so he doesn't smoke forever
  581. waitFor local.self
  582. local.self anim "smoke_into_hand"
  583.  
  584. smoko_loop:
  585.  
  586. local.self anim "smoke_idle"
  587. waitFor local.self
  588. local.randchoice randomint 3
  589. local.randchoice ifequal 0 goto smoko_twitch
  590.  
  591. //if time exceeded goto smoko_end
  592. local.randchoice randomint 5
  593. local.randchoice ifequal 0 goto smoko_end
  594.  
  595. goto smoko_loop
  596.  
  597. smoko_twitch:
  598. local.self anim "smoke_twitch"
  599. waitFor local.self
  600. goto smoko_loop
  601.  
  602. smoko_end:
  603. local.self anim "smoke_finish"
  604. waitFor local.self
  605. local.self state idle
  606. end
  607.  
  608.